<?PHP
/**
 * 数据库类库
 * 
 * @author 大春 lianwanchun@163.com
 * @version 0.1 2010 3 17
 * @copyright Copyright &copy; 2010 lian wan chun
 */

//加载数据库驱动接口
include_once("Db.interface.php");

/**
 * 数据库工厂类
 *
 */
class Database extends LianPhp {
	protected static $_DB;
	/**
	 * 工厂模式加载类驱动
	 *
	 * @param string $driver //加载数据库名称
	 * @return unknown
	 */
	public function factory($driver){
		if(self::$_DB===NULL){
			switch ($driver){
				case "mysql":
					include_once("driver/mysql.class.php");
					self::$_DB = new mysql(LianPhp::conf()->mysql[0],LianPhp::conf()->mysql[1]);
					break;
				case "sqlite":
					include_once("driver/sqlite.class.php");
					self::$_DB = new sqlite(LianPhp::conf()->db);
					break;
			}
		}
		return self::$_DB;
	}
}
?>